import {Injectable} from '@angular/core';
import {HttpService} from '../http.service';
import {tuikeSystemUrl} from '../../../../config/api';

@Injectable()

export class AccountService {

  constructor(
    private httpService: HttpService
  ) {
  }

  /*添加账号*/
  addUser(data) {
    const url = `${tuikeSystemUrl}/api/v1/admin/rbac/admin_add`;
    return this.httpService.httpPostAuth(url, data).map(res => res);
  }

  /*修改账号*/
  editUser(data) {
    const url = `${tuikeSystemUrl}/api/v1/admin/rbac/admin_update`;
    return this.httpService.httpPostAuth(url, data).map(res => res);
  }

  /**
   * 管理员删除
   * @param data
   * @returns {Observable<R>}
   */
  delUser(data) {
    const url = `${tuikeSystemUrl}/api/v1/admin/rbac/admin_delete`;
    return this.httpService.httpPostAuth(url, data).map(data => data);
  }

  /* 管理员信息 */
  getAccountInfo(id) {
    const url = `${tuikeSystemUrl}/api/v1/admin/rbac/admin_info?id=${id}`;
    return this.httpService.httpGetAuth(url).map(res => res);
  }
}
